<?php

namespace App\Service\Coin;

use App\Model\UserCoin;
use App\Model\UserProfile;
use App\Service\BaseService;

/**
 * 我的虚拟币账户
 */
class MyCoinService extends BaseService
{
    public function handle()
    {
        $userId = $this->getUserId();
        $platform = $this->request->input('platform', 2);
        //虚拟币账户信息
        $ret = UserCoin::getUserInfo($userId);
        if ($platform != '1') {
            array_walk($ret, function (&$val) {
                $val = strval($val);
            });
        }
        //是否展示提现入口: 男不展示，女展示
        $profile = UserProfile::getProfile($userId);
        $ret['show_withdraw'] = $profile->gender == 1 ? 0 : 1;
        $ret['total_coin'] < 0 && $ret['total_coin'] = 0;
        log_user_result($userId, $ret);
        return $ret;
    }
}
